package com.ysq.www.api.work.provider;

import com.ysq.www.api.work.entity.CopyTo;
import org.apache.ibatis.annotations.Param;

import java.text.MessageFormat;
import java.util.List;

/**
 * @author dql
 * @Description 抄送记录provider
 * @Date 2020/8/20 0020
 */
public class CopyToProvider {

    public String addList(@Param("list")List<CopyTo> list){
        StringBuilder sb = new StringBuilder();
        sb.append("insert into t_copy_to(type,content_id,user_id,create_time,status) values ");
        MessageFormat mf = new MessageFormat(
                "(#'{'list[{0}].type},#'{'list[{0}].contentId}," +
                        "#'{'list[{0}].userId},#'{'list[{0}].createTime},#'{'list[{0}].status})"
        );
        for (int i = 0;i < list.size();i++){
            sb.append(mf.format(new Object[]{i}));
            if (i < list.size() - 1) sb.append(",");
        }
        return sb.toString();
    }

}
